<?php

$mensaje = _("notienepermisosURL");
$array = $_SESSION['Permisos'];
$actual = $_SERVER['PHP_SELF'];
$actual = split("/", $actual);
$acceso = false;
$primerURL = "";
(int) $i = 1;
foreach ($array as $m) {
    $tempUrl = $m[ds] . ".php";
    if ($i == 1) {
        $primerURL = $tempUrl;
    }
    if ($tempUrl == $actual[2]) {
        $acceso = true;
    }
    $i++;
}
if ($acceso == false) {
    if ($primerURL != "") {
        echo "<script language=Javascript> location.href=\"$primerURL\"; </script>";
    } else {
        echo "<script> alert (\"$mensaje\"); </script>";
        echo "<script language=Javascript> location.href=\"index.php\"; </script>";
    }
}
?>
